// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

#include "SQLCommitStatement.h"
#include "../../visitor/SQLASTVisitor.h"

SQLCommitStatement::SQLCommitStatement()
{
}

SQLObject_ptr SQLCommitStatement::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<SQLCommitStatement>(new SQLCommitStatement());
  std::shared_ptr<SQLCommitStatement> x = std::dynamic_pointer_cast<SQLCommitStatement>(clone_tmp);
  // SQLCommitStatement x = new SQLCommitStatement();
  x->write = write;
  x->wait = wait;
  x->immediate = immediate;
  x->work = work;
  x->chain = chain;
  x->release = release;

  if (transactionName != nullptr)
  {
    x->setTransactionName(std::dynamic_pointer_cast<SQLExpr>(transactionName->clone()));
  }
  if (delayedDurability != nullptr)
  {
    x->setDelayedDurability(std::dynamic_pointer_cast<SQLExpr>(delayedDurability->clone()));
  }
  return x;
}

void SQLCommitStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLCommitStatement)))
  {
    if (transactionName != nullptr)
    {
      transactionName->accept(visitor);
    }

    if (delayedDurability != nullptr)
    {
      delayedDurability->accept(visitor);
    }
  }
  visitor->endVisit(SharedObject(SQLCommitStatement));
}

// oracle
BOOL_ptr SQLCommitStatement::isWrite()
{
  return write;
}

void SQLCommitStatement::setWrite(BOOL_ptr write)
{
  this->write = write;
}

BOOL_ptr SQLCommitStatement::getWait()
{
  return wait;
}

void SQLCommitStatement::setWait(BOOL_ptr wait)
{
  this->wait = wait;
}

BOOL_ptr SQLCommitStatement::getImmediate()
{
  return immediate;
}

void SQLCommitStatement::setImmediate(BOOL_ptr immediate)
{
  this->immediate = immediate;
}

// mysql
BOOL_ptr SQLCommitStatement::getChain()
{
  return chain;
}

void SQLCommitStatement::setChain(BOOL_ptr chain)
{
  this->chain = chain;
}

BOOL_ptr SQLCommitStatement::getRelease()
{
  return release;
}

void SQLCommitStatement::setRelease(BOOL_ptr release)
{
  this->release = release;
}

BOOL_ptr SQLCommitStatement::isWork()
{
  return work;
}

void SQLCommitStatement::setWork(BOOL_ptr work)
{
  this->work = work;
}

// sql server
SQLExpr_ptr SQLCommitStatement::getTransactionName()
{
  return transactionName;
}

void SQLCommitStatement::setTransactionName(SQLExpr_ptr transactionName)
{
  if (transactionName != nullptr)
  {
    transactionName->setParent(SharedObject(SQLCommitStatement));
  }
  this->transactionName = transactionName;
}

SQLExpr_ptr SQLCommitStatement::getDelayedDurability()
{
  return delayedDurability;
}

void SQLCommitStatement::setDelayedDurability(SQLExpr_ptr delayedDurability)
{
  if (delayedDurability != nullptr)
  {
    delayedDurability->setParent(SharedObject(SQLCommitStatement));
  }
  this->delayedDurability = delayedDurability;
}
